package com.dr.cmdb.gateway.config;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;

import java.util.stream.Collectors;

/**
 * @ProjectName: cmdb-gateway
 * @Package: com.dr.cmdb.gateway.config
 * @Description: java类作用描述
 * @Author: duanrui
 * @CreateDate: 2021/4/22 18:06
 * @Version: 1.0
 * <p>
 * Copyright: Copyright (c) 2021
 */
@Configuration
public class MessageConvertersConfig {

    @Bean
    @ConditionalOnMissingBean
    public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
        return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
    }
}
